<?php
class Slash_ACL_FSExt_UriNode extends Sabre_DAV_FSExt_Node
{
	/*
 * Copyright © 2010 Jack Cleaver
 * 
 * This plugin provides functionality added by CalDAV (RFC 4791)
 * It implements new reports, and the MKCALENDAR method.
 *
 * This file is part of Slash.
 *
 * Slash is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Slash is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Slash.  If not, see <http://www.gnu.org/licenses/>.
 *
	 * This class is a nasty hack, to get around the fact that the core FSExt classes
	 * can't tell you what their URI is.
	 */
	private $node;
	
	public function __construct(Sabre_DAV_FSExt_Node $node)
	{
		$this->node = $node;
	}
	
	public function getPath()
	{
		return $this->path;
	}
	
	public function getUri()
	{
		$serverTree = Slash_CalDAV_Server::getInstance()->tree;
		$rootNode = $serverTree->getNodeForPath("/");
		$baseUri = $rootNode->path;
		$nodePath = $this->node->path;
		//Slash_Debug::debug("ACL_FSExt_UriNode getUri: |$baseUri| |$nodePath|");
		if (strpos($nodePath, $baseUri)===0)
		{
			//The path of this starts with $baseUri
			$uri = substr($nodePath, strlen($baseUri));
		}
		return $uri;
	}
}